package leetcode_0003

import "strings"

/**
 * 查找最长的无重复整数
 */
func lengthOfLongestSubstring1(s string) int {

	// 空字符串
	//if len(s) <= 0 {
	//	return 0
	//}

	result, start := 0, 0
	for end := 0; end < len(s); end++ {
		index := strings.Index(s[start:end], string(s[end]))

		// 存在
		if index >= 0 {
			start = start + index + 1
			continue
		}

		if end-start+1 > result {
			result = end - start + 1
		}

	}

	return result
}
